package expressions.slogo;

import java.util.List;
import parsing.Token;

/**
 * Returns a random non-negative integer less than the given max value.
 */
@Token(regex = "random")
public class Random extends TurtleCommand
{

    public Random()
    {
        super(1);
    }

    @Override
    protected Double combineResults(List<Double> results, ITurtleContext context)
    {
        int max = (int) (double) results.get(0);
        java.util.Random r = new java.util.Random();

        return (double) r.nextInt(max);
    }

}
